package top.infopub.enums.fia;

import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/*资金上交--上交方式*/
public enum HandModeEnum {
    //上交方式，1=现金，2=支票，3=网银，4=银行承兑汇票，5=商业承兑汇票，6=银行汇票，7=总部代付工程款，8=其他
    HAND_MODE1("1", "现金"),
    HAND_MODE2("2", "支票"),
    HAND_MODE3("3", "网银"),
    HAND_MODE4("4", "银行承兑汇票"),
    HAND_MODE5("5", "商业承兑汇票"),
    HAND_MODE6("6", "银行汇票"),
    HAND_MODE7("7", "总部代付工程款"),
    HAND_MODE8("8", "其他");

    private String code;

    private String name;

    HandModeEnum(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public static HandModeEnum getByCode(String code) {
        if (StringUtils.isBlank(code)) return null;
        for (HandModeEnum ite : HandModeEnum.values()) {
            if (StringUtils.equals(code, ite.getCode())) {
                return ite;
            }
        }
        return null;
    }

    public static List<Map<String, String>> asList() {
        List<Map<String, String>> list = new ArrayList<>();
        Map<String, String> map;
        for (HandModeEnum ite : HandModeEnum.values()) {
            map = new HashMap<>();
            map.put("code", ite.getCode());
            map.put("name", ite.getName());
            list.add(map);
        }
        return list;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
